<template>
  <!--测试 modelRef -->
  <el-input v-model="val2" placeholder="测试 modelRef"></el-input>
  ({{val2}})
</template>

<script lang="ts">
  import { defineComponent } from 'vue'
  import { ElInput } from 'element-plus'
  import type { PropType } from 'vue'

  import modelRef from '../../../../lib/base/ref/ref-model'

  interface Person {
    name: string,
    age: 12
  }

  export default defineComponent({
    name: 'nf-base-model',
    components: {
      ElInput,
    },
    props: {
      model: {
        type: Object as PropType<Person>,
        default: () => {
          return {
            name: '没有赋值'
          }
        }
      },
      colName: {
        type: String,
        default: 'name'
      }
    },
    setup(props, context) {

      const val2 = modelRef(props.model, 'name')
      // const val2 = modelRef(props.model, props.colName) // 
      // const val3 = modelRef<Person, String>(props.model, props.colName) // 

      return {
        val2
      }
    }
  })
</script>